import Mock from 'mockjs';
import {getResponseData} from './common';

let menuList = [];
menuList.push(Mock.mock(
  {id: '/home', timestamp: +Mock.Random.date('T'), name: '主页', icon: 'home', type: 'item'}
));
menuList.push(Mock.mock(
  {id: '/user', timestamp: +Mock.Random.date('T'), name: '用户管理', icon: 'user', type: 'sub', child: [
    {id: '/user/list', timestamp: +Mock.Random.date('T'), name: '用户列表', icon: 'user', type: 'item'}
  ]}
));
menuList.push(Mock.mock(
  {id: '/thesis', timestamp: +Mock.Random.date('T'), name: '论文管理', icon: 'file-text', type: 'item'}
));
// console.log(menuList);
const count = 8;
let iconTypeList = ['lock', 'unlock', 'area-chart', 'pie-chart', 'bar-chart', 'dot-chart', 'bars', 'book', 'calendar', 'cloud', 'cloud-download', 'code', 'code-o', 'copy', 'credit-card', 'delete', 'desktop', 'download', 'edit', 'ellipsis', 'file', 'file-text', 'file-unknown', 'file-pdf', 'file-word', 'file-excel', 'file-jpg', 'file-ppt', 'file-add', 'folder', 'folder-open', 'folder-add', 'hdd', 'frown', 'frown-o', 'meh', 'meh-o', 'smile', 'smile-o', 'inbox', 'laptop', 'appstore-o', 'appstore', 'line-chart', 'link', 'mail', 'mobile', 'notification', 'paper-clip', 'picture', 'poweroff', 'reload', 'search', 'setting', 'share-alt', 'shopping-cart', 'tablet', 'tag', 'tag-o', 'tags', 'tags-o', 'to-top', 'upload', 'user', 'video-camera', 'home', 'loading', 'loading-3-quarters', 'cloud-upload-o', 'cloud-download-o', 'cloud-upload', 'cloud-o', 'star-o', 'star', 'heart-o', 'heart', 'environment', 'environment-o', 'eye', 'eye-o', 'camera', 'camera-o', 'save', 'team', 'solution', 'phone', 'filter', 'exception', 'export', 'customer-service', 'qrcode', 'scan', 'like', 'like-o', 'dislike', 'dislike-o', 'message', 'pay-circle', 'pay-circle-o', 'calculator', 'pushpin', 'pushpin-o', 'bulb', 'select', 'switcher', 'rocket', 'bell', 'disconnect', 'database', 'compass', 'barcode', 'hourglass', 'key', 'flag', 'layout', 'printer', 'sound', 'usb', 'skin', 'tool', 'sync', 'wifi', 'car', 'schedule', 'user-add', 'user-delete', 'usergroup-add', 'usergroup-delete', 'man', 'woman', 'shop', 'gift', 'idcard', 'medicine-box', 'red-envelope', 'coffee', 'copyright', 'trademark', 'safety', 'wallet', 'bank', 'trophy', 'contacts', 'global', 'shake', 'api', 'fork', 'dashboard', 'form', 'table', 'profile']

for(let i = 0; i < count; i++){
  menuList.push(Mock.mock({
    id: '/test@increment',
    timestamp: +Mock.Random.date('T'),
    name: '@cword(4)',
    'icon|1': iconTypeList,
    'type|1': ['sub', 'item'],
    isMock: true
  }));
}

menuList.forEach((item) => {
  if(item.type === 'sub' && item.isMock) {
    item.child = [];
    let childCount = Math.floor(Math.random() * 100 % 3) + 2;
    for(let i = 0; i < childCount; i++)
    item.child.push(Mock.mock({
      id: '/sub@increment',
      timestamp: +Mock.Random.date('T'),
      name: '@cword(4)',
      'icon|1': iconTypeList,
      type: ['item']
    }));
  }
});

export default {
  getMenu: () => getResponseData(menuList)
}